﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Cosmetic.DataEntity;
using Cosmetic.Logic;
using System.Collections.Generic;
using System.Data.SqlClient;
namespace WebApp.Management.Product
{
    public partial class orderEites : PageBase2
    {
        private OrderManager m_orderManger = new OrderManager();
        private RoleManager m_RoleManager = new RoleManager();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (this.SignInUser1 == null)
            {
                Session.Remove("SignInUser1");
                this.ClientScript.RegisterStartupScript(this.GetType(), this.Title, "alert('请先登录权限!');window.top.location.href='/Management/indexs.aspx';", true);
                return;
            }
            if (!IsPostBack)
            {
                Cosmetic.DataEntity.User theUser = this.SignInUser1;
                if (!this.m_RoleManager.CheckUserRole(theUser, RoleManager.ERole.Admin))
                {
                    Session.Remove("SignInUser1");
                    this.ClientScript.RegisterStartupScript(this.GetType(), this.Title, "alert('你没有管理员权限!');window.top.location.href='/Management/indexs.aspx';", true);
                    return;
                }
            }

            if(!IsPostBack )
            {
            Order theProduct = this.m_orderManger.GetProductById(new Guid(this.Request.QueryString["PID"]));
            this.txtcode.Text  = theProduct.OrderNum;
            this.TextBox1.Text = Convert.ToString  ( theProduct.DeliveryPrice);
            this.txtFlowNum.Text = theProduct.logisticsNum;
            this.ddlExpress.Text = theProduct.ExpressNum;
            //this.TextBox2.Text = Convert.ToString ( theProduct.DeliveryPrice);
            //this.TextBox3.Text = Convert.ToString ( theProduct.Price);
            }
        }

        protected void btnEditProduct_Click(object sender, EventArgs e)
        {
            Order theProduct = this.m_orderManger.GetProductById(new Guid(this.Request.QueryString["PID"]));
            theProduct.State = this.DropDownList1.SelectedValue.ToString();
            theProduct.Valid = true;
            theProduct.DeliveryPrice = Convert.ToDecimal(this.TextBox1.Text);
            theProduct.logisticsNum = this.txtFlowNum.Text;
            theProduct.ExpressNum = this.ddlExpress.SelectedItem.Text;
            m_orderManger.Update();
            this.Page.Response.Redirect("orderlist.aspx");

        }

        protected void txtcode_TextChanged(object sender, EventArgs e)
        {

        }
    }
}
